Improve commit line break unwrapping for variable-length list markers#8417
Improve commit line break unwrapping for variable-length list markers#8417
Conversation
- Fix list continuation to use content indent (not marker indent) - Support variable-length numbered list markers (1., 10., 100., etc.) - Allow flexible continuation spacing (1+ spaces, but not 4+ which is code) - Preserve multi-paragraph list formatting (blank lines within list items) - Track list context across blank lines for proper paragraph unwrapping - Add comprehensive test cases for all scenarios Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Use appendWithSpace with trimmed text to avoid double spaces when joining lines with leading whitespace. Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
| // Pattern to detect list item markers at the start of a line | ||
| const LIST_ITEM_PATTERN = /^[ \t]*([*+\-]|\d+\.)\s/; | ||
| // Pattern to detect list item markers at the start of a line and capture the marker | ||
| const LIST_ITEM_PATTERN = /^([ \t]*)([*+\-]|\d+\.)([ \t]+)/; |
There was a problem hiding this comment.
Updated in f64389c. The regex now uses named capture groups: leadingWhitespace, marker, and markerTrailingWhitespace.
Renamed capture groups for clarity: - leadingWhitespace: spaces/tabs before marker - marker: the list item marker (*, +, -, or digits.) - markerTrailingWhitespace: spaces after marker Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes the commit message body unwrapping logic to correctly handle variable-length list markers, particularly for numbered lists with multi-digit numbers (e.g., 10., 11.). The previous implementation assumed a fixed continuation indent, which broke with multi-digit numbered lists.
Changes:
- Modified
LIST_ITEM_PATTERNregex to use named capture groups for extracting marker components - Replaced simple indent tracking with a stack storing both
markerIndentandcontentIndentfor each list level - Updated blank line handling to preserve list context for multi-paragraph lists
- Added comprehensive test coverage for multi-digit lists, multi-paragraph lists, code blocks within lists, and various continuation indent scenarios
- Included routine updates to VS Code proposed API type definitions
Reviewed changes
Copilot reviewed 2 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/github/folderRepositoryManager.ts |
Core implementation fix: uses named regex captures to calculate proper content indent for variable-length list markers, enabling correct handling of multi-digit numbered lists and multi-paragraph list items |
src/test/github/folderRepositoryManager.test.ts |
Adds 13 new test cases covering multi-digit numbered lists, multi-paragraph lists, code blocks within lists, variable space continuations, and nested variations |
src/@types/vscode.proposed.chatSessionsProvider.d.ts |
Updates proposed API type definitions to add CancellationToken parameter to refresh handlers and simplifies changes property types |
src/@types/vscode.proposed.chatParticipantPrivate.d.ts |
Bumps API version from 11 to 12 |
src/@types/vscode.proposed.chatParticipantAdditions.d.ts |
Adds new ChatQuestion and ChatResponseQuestionCarouselPart types for question carousel UI feature |
src/@types/vscode.proposed.chatContextProvider.d.ts |
Refactors context provider APIs into separate workspace, explicit, and resource provider interfaces with clearer separation of concerns |
| * - For a resource. Make sure to pass a selector that matches the resource you want to provide context for. | ||
| * Providers registered without a selector will not be called for resource-based context. | ||
| * - Explicitly. These context items are shown as options when the user explicitly attaches context. | ||
| * Register a chat workspace context provider. Workspace context is automatically included in all chat requests. |
There was a problem hiding this comment.
They get updated as part of npm install, which Copilot runs.
The previous implementation incorrectly prevented joining list
continuations when the next line was a list item at the same level.
This caused wrapped list content to not be unwrapped properly.
Changes:
- Remove incorrect check that prevented joining based on next line
- Remove unused getNextNonBlankLineInfo function
- Update test names and expectations to reflect correct behavior:
- List continuations should be unwrapped (joined), not preserved
- Renamed 'preserves list item continuations' to 'unwraps list item
continuations'
- Renamed 'unwraps regular text but preserves list item continuations'
to 'unwraps regular text and list item continuations'
- Fixed expected output for nested list content tests
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Fixed in 9ff7c15. The issue was that the |
When a list item is followed by a wrapped line that has no indentation (but is not itself a list item), the line should be joined to the previous list item. This is common in commit messages wrapped at 72 chars. The fix moves the handling of non-indented continuations BEFORE calling getActiveListContentIndent, which was clearing the list stack and preventing the join from happening. Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Fixed in a10759d. The issue was that |
Move the unwrapCommitMessageBody function from folderRepositoryManager.ts to gitUtils.ts as a reusable utility function. Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
unwrapCommitMessageBodyfunctionfolderRepositoryManager.test.tsactiveIndent + 2) but numbered list markers can be variable-length (e.g.,1.vs10.)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.